package com.mac.cxcybackground.controller;

import com.mac.cxcybackground.bean.Users;
import com.mac.cxcybackground.mapper.UsersMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

@Controller
public class RegisterationController {

    @Autowired
    UsersMapper usersMapper;

    @GetMapping("/registration")
    public String registeration(){
        return "registration";
    }
    @PostMapping("/data/registration")
    public String registerationAdd(Users users, Model model){
        Users user = new Users();
        user.setUserName(users.getUserName());
        user.setPassword(users.getPassword());
        usersMapper.insert(user);
        model.addAttribute("msg","已经注册成功,请登录");
        return "login";
    }
}
